<?php
# ***** BEGIN LICENSE BLOCK *****
# This file is part of "myWiWall".
# Copyright (c) 2007-2008 CRP Henri Tudor and contributors.
# All rights reserved.
#
# "myWiWall" is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
# 
# "myWiWall" is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with "myWiWall"; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# ***** END LICENSE BLOCK *****


/**
 * The Wall Module class regroups actions relevant to the Widget Wall of a user.
 *
 * @author Laurent Haan <laurent.haan@gmail.com>
 * @author J�r�me Bogaerts <jerome.bogaerts@gmail.com>
 * @package mywiwall.actions
 */
class Wall
{
	/**
	 * The index action is the default action of this Wall Module. It prepares the widget
	 * wall of the user and render the view according to its preferences.
	 * 
	 * If the current user is not authenticated, it will be redirected to the users/index
	 * action that will allows you to acces the login form of the application.
	 *
	 */
	public function index()
	{
		if (Auth::isAuth())
		{
			// Determine if the 'category widget' is installed.
			if (Widgets::isInstalled('categoryList'))
				$widgetCategory = array('id' => 'categoryList',
										'name' => 'Widget Categories');
				
			// Determine if the 'tag cloud widget' is installed.
			if (Widgets::isInstalled('tagCloud'))
				$widgetCloud = array('id' => 'tagCloud',
									 'name' => 'Widget Tag Cloud');
				
			// Determine if the view must allow the user to manage widgets.
			$widgetManagement = false;
			if (Auth::isAdmin() || Auth::isGod())
				$widgetManagement = true;
				
			// Determine if the view must show the list of installed widgets or
			// a link to the PALETTE Service Browser.
			$useServiceBrowser = USE_SERVICE_BROWSER;
			$serviceBrowserURI = (USE_SERVICE_BROWSER) ? (SERVICE_BROWSER_URI . 'index.php/Services/Widgets?num=1') : null;
			
			// Determine if we need to show user preferences.
			$displayPreferences = true;
			
			
			require(DefaultFC::getView('index.tpl'));
		}
		else
		{
			DefaultFC::redirection('users/index?ref=wall');
		}
	}
}
?>